004 basic controls

嘿伙计们欢迎回来。
Hey guys welcome back.

现在我们的通信已经设置完成一半了,让我们继续尝试将一些控件放到屏幕上。
Now we've got our communications halfway set up and let's go ahead and try to drop some controls onto our screen.

由于我正在了解 RPO 的信息,因此我们要做的第一件事就是我们已经在我的提前阶段设置了通信,因此如果我单击我们的通信驱动程序 RDF,您可以看到我们已设置完毕最多使用CRC校验和类型进行通信。
And since I'm information into RPO see the first thing we want to do is we've already got our communications set up in advance stage in my so if I click on our communications driver RDF one come one you can see we're set up to communicate using CRC checksum type.

这是发送信息来的。
And this is sending information on come for.

我们还需要设置模拟来进行通信。
Well we also need to set up emulate to communicate as well.

那么让我们继续前进吧。
So let's go ahead and come in here.

让我们进入设置通道 0 数据高速公路,我们也想在这里设置我们的端口。
Let's just go into settings Channel 0 data highway and we want to set our port here to come too.

因为请记住,当我们查看 com 0 com 时,我们将 4 和 2 连接在一起。
Because remember when we look at com zero com we are linking comes four and two together.

因此,我们已经有了高级 Chimayo,因为我们需要将 immolate 放在 come to 上,然后进行错误检测,让我们继续将其设置为 CRC。
So we've got advanced Chimayo and come for we need to put immolate on come to and then for our error detection Let's go ahead and set that to CRC.

所以此时一切都应该沟通良好。
So at this point everything should communicate fine.

我们可以点击“确定”,然后返回 Visual Studio 并开始让一切正常运行。
We can hit OK there and then let's come back into Visual Studio and start to make things work.

所以我想做的第一件事就是展开左侧的工具箱,我将折叠组件中的这个高级阶段,并且折叠我的驱动程序,以便我实际上只是查看我的控件组件,我们要学习的第一件事是如何创建按钮。
So first thing I'm want to do is expand my tool box on the left and I'm just going to collapse this advance stage in my components and I'm going to collapse my drivers so that I'm really just looking at my controls components and the first thing we want to learn is how do we create a button.

因此,我将单击基本按钮,将其拖到此处,然后在屏幕上松开。
So I'm going to click basic button drag it over here and then let go on the screen.

现在我有了这个非常简单非常小、看起来很丑的按钮,我们甚至无法阅读,这是完美的。
And now I've got this really simple really small kind of ugly looking button that we can't even read that's perfect.

因此,让我们单击该按钮,一旦突出显示,我们就可以在右侧获得该按钮的属性。
So let's click on that and once that's highlighted we get the properties for that button over here on the right.

我首先要寻找的是颜色。
And the first thing I want to look for is this for color.

我不喜欢浅灰色的白色。
And I don't like that being white on light gray.

那么让我们继续将其更改为黑色。
So let's go ahead and change that to black.

现在我们可以实际阅读它,它写的是 basic Boo。
So now we can actually read it and it says basic Boo.

嗯,这是因为文本设置为基本按钮 1,这对我们来说并不是特别有用,所以我将把它更改为开始。
Well that's because the text is set to say basic button 1 which isn't particularly useful to us so I'm going to change that to say start.

所以现在我们实际上正在创建一些看起来像开始按钮的东西。
So now we're actually creating something that looks like a start button.

现在,我将一直向下滚动到属性底部,这里有我的 PLCC 属性,我们可以看到它已经设置为通过 DFI 进行一一通信。
Now I'm going to scroll all the way down towards the bottom of my properties and I've got my PLCC properties here where we can see that it's already set up to communicate over DFI one come one.

我们实际上并不需要担心这两个保持时间,但是如果您看到我们有一些不同的方式可以使该按钮发挥作用,那么我确实想指出这种输出类型,就像我们在其他 H 上有不同类型的按钮功能一样套房。
We don't really need to worry about these two hold times but this output type is something I do want to point out if you look we have some different ways that this button can function just like we have different types of button functionality on other H suites.

所以这非常有用,你可以暂时重置,将其设置为 True 或 False 切换它。
So that's pretty useful you've got momentary reset set it to True or False toggle it.

在我们的例子中,我们只是将其保留为瞬时设置,因为正如我总是说的,对于我们的按钮,我们的 HDMI 是我总是建议使用瞬时按钮。
In our case we're just going to leave it to momentary set because as I always say for our push buttons our HDMI is I always recommend using momentary pushbuttons.

接下来我们看到的是 PLCC 地址。
The next thing we come to is our PLCC address.

点击。
Click.

那么,当我们单击此按钮时,我们正在使用什么地址。
So when we click on this button What address are we working with.

好吧,让我们拉起鲍里斯逻辑,开始按钮就是我们真正想要设置的。
Well let's pull up Boris logic's and the start button is what we actually want to set.

那个设置在 B-3 冒号三斜线三上。
And that set on B-3 colon three slash three.

所以我要回到这里,然后就这样把它打出来。
So I'm going to come back in here and I'm going to type it out just like that.

B-3 冒号三斜线三。
B-3 colon three slash three.

这将设置地址。
And that's going to set the address.

我们要写信给。
We're going to write to.

如果我们现在往下看这个要写入的值,我们会尝试设置一个不为零的值,所以让我们继续将零更改为 1。
And if we look down here under this value to write right now we're trying to set a one not zero so let's go ahead and change that zero to a 1.

现在,当我们尝试运行这个东西时,我们实际上将设置该位为真。
Now we're actually going to be setting that bit is true when we try to run this thing up.

所以到那时我认为我们确实已经准备好了我们需要的一切。
So at that point I think we've really got everything set that we need to.

我将转到此窗口的顶部,然后单击“开始”并运行此程序。
I'm just going to come up here to the top of this window and click start and get this thing running.

现在让我们看看在测试该按钮之前我们已经有了窗口。
Now let's see there we go we've got our window right here before we test that button.

让我们回到我们的程序,我将通过切换系统停止位来启动我们的系统。
Let's come back into our program and I'm going to start our system by toggling the system stop bit.

所以现在你可以看到系统运行已断电。
So now you can see system running is de-energized.

当我按下 HDMI 上的启动按钮时,我希望将 B-3 3 设置为 true,这将使我的系统开始运行。
And when I push my start button on my HDMI I would expect to set B-3 three to true which would cause my system to start running.

让我们看看这种情况是否会发生。
And let's see if that happens.

它没有发生。
It didn't happen.

不仅如此,看起来我刚刚破坏了我的应用程序,所以我得到了这个索引超出范围的异常未处理。
And not only that it looks like I've just broken my application so I've got this index out-of-range exception was unhandled.

现在为什么会发生这种情况。
Now why did that happen.

好吧,因为 Visual Basic 代码中的某些内容被破坏了,即使我们不是 Visual Basic 开发人员,仅仅通过尝试创建一个按钮,我们现在就被扔进了一页充满了看起来非常令人生畏的 Visual Basic 的中间。
Well because something in the Visual Basic code is broken and even though we are not Visual Basic developers just by trying to create one button we're now thrown into the middle of a page full of very intimidating looking Visual Basic.

所以它说这个索引超出了范围,我们在这里有一个很好的小for循环,它告诉我我必须比它应该有的数字更高。
So it says This index is out of range and we've got this nice little for loop here which tells me that I got to be a number higher than it should have.

我想我也许可以通过将这一点改为两点来解决这个问题。
And I think I might be able to solve that by just changing this one to two.

我将继续走到这里并单击这个红色停止调试按钮,然后让我们尝试保存我的应用程序,然后再次开始。
I will go ahead and come up here and click on this red stop debugging button and then let's try to save my application and then started again.

让我们看看这是否能解决我们的问题并让我们进行沟通。
And let's see if that fixes us and gets us communicating.

所以我要拉出我的程序,然后我要把我的窗口拉到这里,让我们尝试单击开始。
So I'm going to pull up my program and then I'm going to pull my window over here and let's try and click start.

答对了。
Bingo.

就这样。
Just like that.

现在我们实际上已经发送了信息,您可以看到我们已经让系统开始运行。
Now we've actually sent the information in and you can see we've got the system running to start up.

现在我们已经可以工作了,这很好,但问题是为什么我们必须进入 Visual Basic 代码。
Now that's good that we've got it working but the problem is man why do we have to get into Visual Basic code.

你知道我是一名程序员,我不是 Visual Basic 程序员,但我知道如何使用 for 循环。
And you know I am a programmer I'm not a Visual Basic programmer but I know how to use a for loop.

因此,当我看到超出范围的异常时,我知道如何修复它。
So when I see that out of bounds kind of exception I have an idea how to fix it.

但为什么我需要参与这个。
But why do I need to get into this.

如果我尝试发展一个完整的我的。
And if I try to develop a full on h my.

我是否会有很多这样的事情需要处理?
Am I going to have a lot of these things to have to deal with.

你知道这就是为什么我不是高级舞台的超级粉丝,但从好的方面来看。
You know that's why I'm not a huge fan of advanced stage or my but on the bright side look at that.

我们的开始按钮可以工作了。
We've got our start button working.

果然它正在向我们的 PLCC 发送信息。
And sure enough it is sending information into our PLCC.

因此,当我按住该按钮时,如果你向左看三三三,你可以看到它充满活力,当我单击并释放该按钮时,你会看到它充满活力。
So when I hold that button if you look to the left and be three three three you can see it energizing and the energizing as I click and release that button.

所以我们正在沟通,现在我们知道如何在屏幕上构建基本控件并发送一些信息。
So we are communicating and we now know how to build a basic control on our screen and send some information in.

因此,我们接下来想要知道如何做的是如何将模拟值写入海中。
So the next thing we're going to want to know how to do is how do we write an analog value into the sea.

因此,如果我们回到工具箱,您可能会期待诸如数字输入或数字输入之类的内容。
So if we come back into tool box you look you might be expecting something that says like numeric entry or numeric input or something like that.

如果你仔细查看这个列表,你会发现它确实不存在。
And if you look through this list and it really doesn't exist.

那么我们如何发送一个数值呢?
So how do we send in a numeric value.

看一下这个。
Check this out.

我们将在我们的程序中添加一个基本标签,您知道这是我们通常用来在屏幕上显示文本或类似内容的东西。
We're going to pull a basic label into our program and you know this is something that we would generally use to just display text on the screen or something like that.

但在这种情况下,这实际上是我们必须用来发送号码的工具,所以我得到了基本标签。
But in this case where this is actually the tool that we're going to have to use to send in a number so I've got my basic label.

让我们向下滚动到这里并找到 PLCC 属性,然后我们得到这个 PLCC 地址键盘。
Let's scroll down here and find our PLCC properties and then we get this PLCC address keypad.

这就是我们要设置要写入的整数或浮点地址的地方。
And that's where we're going to set an integer or float address to write into.

那么对于我们来说,写什么是一件好事。
So what would be a good thing for us to write.

让我们重新打开我们的程序,假设我们想要手动设置水箱液位。
Let's pull back open our program and let's pretend that we want to manually set our tank level.

在这里我们可以看到我们的水箱液位大约为 60%,并且正在下降。
So here we can see our tank level is running at about 60 percent and it's going down.

如果我们进入 IO 并向下滚动到此处的实际电平控制,我们会看到 F-8 2 实际上是根据来自 N 10 冒号的原始信号设置的,这是我正在使用的整数。
And if we go into our IO and scroll down to our actual level control which is right here we see that F-8 2 is actually being set based on the raw signal from N 10 colon to which is the integer I'm using.

因此,如果我们将原始值写入 n 10 冒号,那么我们应该能够操纵水箱液位。
So if we write a raw value to n 10 colon to then we should be able to manipulate our tank level.

这就是我们要尝试做的事情。
So that's what we're going to try to do.

我们回到这里吧。
Let's come back in here.

在这个 PLCC 地址下,我们也将输入任何人的零冒号。
And under this PLCC address keep we're going to type in anyone's zero colon too.

那应该可以了。
And that should do it.

因此,对于这个基本标签,这里还要向上滚动一点并找到我的字体信息,然后我还将设置我的 PLCC 地址值。
So for this basic label here also going to scroll up a little bit and find my font information and then I'm also going to set my PLCC address value.

我还将设置十分之二的冒号。
I'm also going to set that two in 10 colon too.

这样,它将向我显示实际发送的原始储罐液位值,然后我也可以写入该值。
So that way it will show me the value that's actually being sent in for the raw tank level and then I'll also be able to write that value.

那么,让我们开始吧,希望我们能看到一个正在发生变化的标签。
So let's hit start and hopefully we'll see a label that's changing.

我们开始吧。
There we go.

我们的原始值的变化是由 C 程序控制的,我想将该程序拉出来并将其放在我们旁边,这样我们就可以看到这是相同的值。
There's our raw value changing just being controlled by the C program and I want to pull that program up and kind of get it next to us so we can see that's the same value.

然后当我点击它时,我会看到一个看起来像计算器的小输入板,它出现并说我想将其一直设置到 4000。
And then when I click on that I get this little calculator looking entry pad that comes up and say I want to set that thing all the way down to 4000.

所以我只要输入 4000 次点击回车,果然我的坦克水平就根据其原始值一路下降到 22%。
So I just type in my 4000 hit enter and sure enough my tank level just dropped all the way down to 22 percent based on their raw value.

所以此时我可以发送比特,也可以发送数字。
So at this point I can send in bits and I can also send in numbers.

这确实是控制自然所需要做的全部事情。
And that's really all you ever need to do for controls on a nature.

如果你能把这两件事寄出去,那就太好了。
If you can send in those two things you're good.

我将在此处结束本次讲座,我们将在下一次回顾。
I'll wrap this lecture up here and we will check back in in the next.

我们将开始制作一些显示器。
And we will start working on some displays.

那么到时候见。
So see you then.

干杯。
Cheers.